<?php

namespace App\Http\Controllers\Api;

use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Redis;
use Illuminate\Support\Str;

class BroadcastController extends Controller
{
   public function test(Request $request)
   {
       $msg = $request->input('msg');
       Redis::set('msg',$msg);
       Redis::publish('message',json_encode([
           'id'=>Str::random(16),
           'msg'=>$msg
       ]));
       broadcast(new \App\Events\Message($msg));
   }
}
